<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2018-03-02 17:14:35 apple $
*/
namespace core;
defined('BY_JYA') or exit('error');
class content{
	public function up_article(){
		$group_id=pdo_getcolumn('core_account_content_group',array('systype'=>1,'type'=>'news','uniacid'=>$_SESSION['uniacid']),'id');
		$pindex=max(1,intval($_RQ['page']));
		$psize=1;
		$params=array('group_id'=>$group_id,'type'=>'news','uniacid'=>$_SESSION['uniacid']);
		$total=0;
		$max=pdo_getslice('core_account_content',$params,array($pindex,$psize),$total,$fields,'','fromid desc');
		$maxid=$max[0]['fromid'];
		$fields=array('id','title','pic_url','plugin_name','createtime');
		$list=pdo_getall('core_account_article',array('id >'=>$maxid,'uniacid'=>$_SESSION['uniacid']),$fields,'','id asc');
		if(count($list) && $group_id){
			foreach($list as &$item){
				$isadd=pdo_getcolumn('core_account_content',array('fromid'=>$item['id'],'group_id'=>$group_id,'type'=>'news','uniacid'=>$_SESSION['uniacid']),'id');
				if($isadd || !$item['title']){
					continue;
				}
				$data=array(
					'fromid'=>$item['id'],
					'star'=>$item['star'],
					'title'=>trim($item['title']),
					'h5url'=>'core/article.list/detail/id='.$item['id'],
					'group_id'=>$group_id,
					'pluginname'=>$item['plugin_name'],
					'image'=>trim($item['pic_url'])
				);
				$data['type']='news';
				$data['uniacid']=$_SESSION['uniacid'];
				$data['createtime']=TIMESTAMP;
				pdo_insert('core_account_content',$data);
			}
		}
		return true;
	}
	public function up_website(){
		$group_id=pdo_getcolumn('core_account_content_group',array('systype'=>2,'type'=>'news','uniacid'=>$_SESSION['uniacid']),'id');
		$pindex=max(1,intval($_RQ['page']));
		$psize=1;
		$params=array('group_id'=>$group_id,'type'=>'news','uniacid'=>$_SESSION['uniacid']);
		$total=0;
		$max=pdo_getslice('core_account_content',$params,array($pindex,$psize),$total,$fields,'','fromid desc');
		$maxid=$max[0]['fromid'];
		$fields=array('id','title','star','createtime');
		$list=pdo_getall('core_mobile_web',array('id >'=>$maxid,'uniacid'=>$_SESSION['uniacid'],'webid'=>0,'pctype <='=>1),$fields,'','id asc');
		if(count($list) && $group_id){
			foreach($list as &$item){
				$isadd=pdo_getcolumn('core_account_content',array('fromid'=>$item['id'],'group_id'=>$group_id,'type'=>'news','uniacid'=>$_SESSION['uniacid']),'id');
				if($isadd || !$item['title']){
					continue;
				}
				$data=array(
					'fromid'=>$item['id'],
					'star'=>$item['star'],
					'title'=>trim($item['title']),
					'h5url'=>'core/welcome//id='.$item['id'],
					'group_id'=>$group_id,
					'image'=>trim($item['image'])
				);
				$data['type']='news';
				$data['uniacid']=$_SESSION['uniacid'];
				$data['createtime']=TIMESTAMP;
				pdo_insert('core_account_content',$data);
			}
		}
		return true;
	}
	public function up_goods(){
		$group_id=pdo_getcolumn('core_account_content_group',array('systype'=>3,'type'=>'news','uniacid'=>$_SESSION['uniacid']),'id');
		$pindex=max(1,intval($_RQ['page']));
		$psize=1;
		$params=array('group_id'=>$group_id,'type'=>'news','uniacid'=>$_SESSION['uniacid']);
		$total=0;
		$max=pdo_getslice('core_account_content',$params,array($pindex,$psize),$total,$fields,'','fromid desc');
		$maxid=$max[0]['fromid'];
		$fields=array('id','title','image','pluginname','createtime');
		$list=pdo_getall('jy_weishop_goods',array('id >'=>$maxid,'uniacid'=>$_SESSION['uniacid']),$fields,'','id asc');
		if(count($list) && $group_id){
			foreach($list as &$item){
				$isadd=pdo_getcolumn('core_account_content',array('fromid'=>$item['id'],'group_id'=>$group_id,'type'=>'news','uniacid'=>$_SESSION['uniacid']),'id');
				if($isadd || !$item['title']){
					continue;
				}
				$data=array(
					'fromid'=>$item['id'],
					'star'=>$item['star'],
					'title'=>trim($item['title']),
					'h5url'=>'jy_weishop/goods.detail//id='.$item['id'],
					'group_id'=>$group_id,
					'pluginname'=>$item['pluginname'],
					'image'=>trim($item['image'])
				);
				$data['type']='news';
				$data['uniacid']=$_SESSION['uniacid'];
				$data['createtime']=TIMESTAMP;
				pdo_insert('core_account_content',$data);
			}
		}
		return true;
	}
}